
#ifndef  __DRIVER_H__
#define  __DRIVER_H__

#ifdef _cplusplus
extern "c"{
#endif
#include "typedef.h"
#include "Queue.h"

//#ifndef Xuint8
typedef unsigned char	Xuint8;		/**< unsigned 8-bit */
typedef char		Xint8;		/**< signed 8-bit */
typedef unsigned short	Xuint16;	/**< unsigned 16-bit */
typedef short		Xint16;		/**< signed 16-bit */
typedef unsigned long	Xuint32;	/**< unsigned 32-bit */
typedef long		Xint32;		/**< signed 32-bit */
typedef float		Xfloat32;	/**< 32-bit floating point */
typedef double		Xfloat64;	/**< 64-bit double precision FP */
typedef unsigned long	Xboolean;	/**< boolean (XTRUE or XFALSE) *///#endif
typedef int XStatus;

//Driver_i2c.h
typedef Xuint8 (*I2c_WorkState_Get_Fun)(Xuint8 deviceId);
extern I2c_WorkState_Get_Fun I2c_WorkState_Get_Ex;
typedef XStatus (*I2c_Module_Ena_Fun)(Xuint8 deviceId,Xuint8 ena);
extern I2c_Module_Ena_Fun I2c_Module_Ena_Ex;
//Driver_i2c.h end 

//driver_init.h
typedef unsigned char  (*Get_Owerner_Sit_Num_Fun)();
extern Get_Owerner_Sit_Num_Fun Get_Owerner_Sit_Num_Ex;
//driver_init end

//driver_logic.h
typedef Xuint8 (*Get_GlbIntrpt_Pend_Fun)();
extern Get_GlbIntrpt_Pend_Fun Get_GlbIntrpt_Pend_Ex;
typedef Xuint8 (*Set_GlbIntrpt_Enab_Fun)(Xuint8 ena);
extern Set_GlbIntrpt_Enab_Fun Set_GlbIntrpt_Enab_Ex;
typedef XStatus (*Set_Ipmb_Enable_Fun)(Xuint8 channel_num,Xuint8 ena);
extern Set_Ipmb_Enable_Fun Set_Ipmb_Enable_Ex;
typedef void (*Clr_Reset_Status_Fun)();
extern Clr_Reset_Status_Fun Clr_Reset_Status_Ex;
typedef Xuint8 (*Get_Reset_Status_Fun)();
extern Get_Reset_Status_Fun Get_Reset_Status_Ex;

typedef Xboolean (*Get_Swap_IsClose_Fun)();
extern Get_Swap_IsClose_Fun Get_Swap_IsClose_Ex;
typedef Xboolean (*Get_PwrPs1_IsClose_Fun)();
extern Get_PwrPs1_IsClose_Fun Get_PwrPs1_IsClose_Ex;

typedef Xuint8 (*Get_PowerOk_Value_Fun)();
extern Get_PowerOk_Value_Fun Get_PowerOk_Value_Ex;

typedef XStatus (*Set_PowerOk_Out_Fun)(Xuint8 ok);
extern Set_PowerOk_Out_Fun Set_PowerOk_Out_Ex;

typedef XStatus (*Set_SMP_Enable_Fun)(Xuint8 ena);
extern Set_SMP_Enable_Fun Set_SMP_Enable_Ex;

typedef XStatus (*Set_LedBlue_State_Fun)(Xuint8 ena);
extern Set_LedBlue_State_Fun Set_LedBlue_State_Ex;
typedef XStatus (*Set_LedAlarm_State_Fun)(Xuint8 ena);
extern Set_LedAlarm_State_Fun Set_LedAlarm_State_Ex;
typedef XStatus (*Set_LedRun_State_Fun)(Xuint8 ena);
extern Set_LedRun_State_Fun Set_LedRun_State_Ex;
XStatus Set_LedRun_State(Xuint8 state);

typedef Xuint8 (*Get_Board_Ps1_Fun)(Xuint8 board_num);
extern Get_Board_Ps1_Fun Get_Board_Ps1_Ex;
typedef XStatus (*Set_Board_Enable_Fun)(Xuint8 board_num,Xuint8 ena);
extern Set_Board_Enable_Fun Set_Board_Enable_Ex;
typedef Xuint8 (*Get_Board_Enable_Fun)(Xuint8 board_num);
extern Get_Board_Enable_Fun Get_Board_Enable_Ex;

typedef XStatus (*Set_Mpower_Enable_Fun)(Xuint8 board_num,Xuint8 ena);
extern Set_Mpower_Enable_Fun Set_Mpower_Enable_Ex;
typedef Xuint8 (*Get_Mpower_Enable_Fun)(Xuint8 board_num);
extern Get_Mpower_Enable_Fun Get_Mpower_Enable_Ex;
//driver_logic end

//driver_i2c.h
typedef XStatus (*Enable_Payload_Power_Fun)(Xuint8 channel_num,Xuint8 enable,Xuint8 master);
extern Enable_Payload_Power_Fun Enable_Payload_Power_Ex;
typedef XStatus (*ReadLtc4222_Fun)(Xuint8 channel,Xuint8 cmd,Xuint16* p_data);
extern ReadLtc4222_Fun ReadLtc4222_Ex;
//driver_i2c.h end

//i2c_module_interface.h
#define MAX_BUS_DATAPACKET	20
#define BUS_DATAPACKET_SIZE	64
#define MAX_BUS_EVENT		64
typedef void (* IicDriverNotifyFun)(Xuint8 deviceId,Xuint8 eventInd);
typedef struct _BusDataPacket
{
	uint8	m_Data[BUS_DATAPACKET_SIZE];
	uint16	m_Len;
}BusDataPacket;

typedef struct _IicDriver
{
	uint8	m_Channel;
	//uint8	m_BusState;

	IicDriverNotifyFun Notify;

	Queue			m_ReceiveDataQueue;
	BusDataPacket	m_ReceiveDataQueueBuff[MAX_BUS_DATAPACKET];

	Queue			m_SendDataQueue;
	BusDataPacket	m_SendDataQueueBuff[MAX_BUS_DATAPACKET];

	Queue	m_EventQueue;
	uint32	m_EventQueueBuff[MAX_BUS_EVENT];
}IicDriver;
#define MAX_IICDRIVER	4
extern IicDriver* g_pIicDriverArray[MAX_IICDRIVER];

typedef void (*I2c_InterruptHandler_Fun)(Xuint8 channel_num);
extern I2c_InterruptHandler_Fun I2c_InterruptHandler_Ex;
typedef XStatus (*ReadLtc4222_Fun)(Xuint8 channel,Xuint8 cmd,Xuint16* p_data);
extern ReadLtc4222_Fun ReadLtc4222_Ex;

typedef int (*I2C_TxData_Fun)(Xuint8 ChanNum,Xuint8 DataLen,void * DataBuf);
extern I2C_TxData_Fun I2C_TxData_Ex ;
typedef int (*I2C_RxData_Fun)(Xuint8 ChanNum,Xuint8 MaxLen,void * DataBuf);
extern I2C_RxData_Fun I2C_RxData_Ex ;
typedef int (*I2C_GetStatus_Fun)(Xuint8 ChanNum,Xuint8 * RxBufStatus,Xuint8 * TxBufStatus,Xuint8 * EventStatus);
extern I2C_GetStatus_Fun I2C_GetStatus_Ex ;
typedef int (*I2c_Device_Read_Fun)(Xuint8 ChanNum,Xuint8 *SendData,Xuint8 SendLen,Xuint8 *RecvData,Xuint8 RecvLen);
extern I2c_Device_Read_Fun I2c_Device_Read_Ex ;

void IicDriver_SendToEmmc(IicDriver* pIicDriver, uint8* pData, uint8 len);
IicDriver* IicDriver_Get(uint8 channel);
//i2c_module_interface.h end

typedef void (*tSleep)(int times);
extern tSleep mSleep;


#define MAX_FRUINFO_SIZE 8192
extern uint8 g_FruDeviceBuffer[MAX_FRUINFO_SIZE];

#ifdef _cplusplus
}
#endif

#endif 

